package com.yzy.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yzy.entity.File;
import com.yzy.entity.User;
import com.yzy.mapper.FileMapper;
import org.springframework.jdbc.object.UpdatableSqlQuery;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.management.Query;
import java.util.List;

@Service
public class FileService extends ServiceImpl<FileMapper, File> {

    @Resource
    private FileMapper fileMapper;

    public List<File> search(Integer uploadUserId){
        QueryWrapper<File> wrapper=new QueryWrapper<>();
        wrapper.eq("upload_user_id",uploadUserId);
        return  list(wrapper);

    }
    /**
     * @description 根据商品id和用户id判断用户是否购买过该商品，如果是，则返回文件的下载地址
     * @param userId 用户id
     * @param goodId 商品id
     * @return java.lang.String
     * @author mgl
     * @date 2023/7/16 12:54
     */
    public String getFilePath(Integer userId,Integer goodId){
        return fileMapper.getFilePath(userId,goodId);
    }

}
